<template>
  <div>
    <!-- 视频 -->
    <div class="videoBox" @click="mvplayend">
      <video :src="mvUrl" autoplay controls></video> 
      <!-- <span v-show="flag" class="iconfont icon-bofang413"></span> -->
      <div class="button" @click="$router.go(-1)">
        <span class="iconfont icon-arrow-left-bold"></span>
        MV
      </div>
    </div>
    <!-- MV数据 -->
    <div class="mvdata">
      <div class="song">
        <div class="song-Name">
          <img :src="mvdata.cover" alt="">
          <span>{{mvdata.artistName}}</span>
        </div>
        <div class="title">
          {{mvdata.name}}
          <span>{{mvdata.publishTime}}</span>
        </div>
      </div>
      <div class="content">
        <div class="packUp" @click="nounShow" v-show="noun">
          {{mvdata.desc}}
        </div>
        <div class="expansion"  @click="nounShow" v-show="!noun">
          {{mvdata.desc}}
        </div>
      </div>

    </div>
    <!-- 评论 -->
    <div class="comment">
      <h4>热门评论({{ hotComments.length }})</h4>
      <ul>
        <li v-for="(item, index) in hotComments" :key="index">
          <div class="com-Img">
            <img :src="item.user.avatarUrl + '?param=50y50'" alt="" />
          </div>
          <div class="com-text">
            <p class="user">{{ item.user.nickname }}</p>
            <p class="text">{{ item.content }}</p>
          </div>
        </li>
      </ul>
    </div>

    <div class="comment">
      <h4>评论({{ comments.length }})</h4>
      <ul>
        <li v-for="(item, index) in comments" :key="index">
          <div class="com-Img">
            <img :src="item.user.avatarUrl + '?param=50y50'" alt="" />
          </div>
          <div class="com-text">
            <p class="user">{{ item.user.nickname }}</p>
            <p class="text">{{ item.content }}</p>
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import { getMvUrl, getCommentMv,getMvDetail } from "../../api/mvDetails";
export default {
  data() {
    return {
      mvUrl: "",
      hotComments: [], // 热评
      comments: [],
      flag: false,
      mvdata:[], // mv数据
      noun: true,
    };
  },
  methods: {
    // 获取MV URl
    getMvUrlFun() {
      getMvUrl({ id: this.$route.query.id }).then((data) => {
        this.mvUrl = data.data.url;
      });
    },
    // 获取评论
    getCommentMvFun() {
      getCommentMv({ id: this.$route.query.id }).then((data) => {
        this.hotComments = data.hotComments; // 热评
        this.comments = data.comments; // 评论
      });
    },
    // 获取mv数据
    getMvDetailFun(){
      getMvDetail({ mvid: this.$route.query.id }).then(data=>{
        console.log(data.data)
        this.mvdata = data.data
      })
    },
    nounShow(){
      this.noun = !this.noun;
    },
    mvplayend(event) {
      this.flag = !this.flag;
      if (this.flag) {
        event.target.pause();
      } else {
        event.target.play();
      }
    },
  },
  created() {
    this.getMvUrlFun();
    this.getCommentMvFun();
    this.getMvDetailFun()
  },
}
</script>

<style lang="less">
// mv数据
.mvdata{
  padding: 10px;
  .song{
    .song-Name{
        img{
          width: 50px;
          height: 50px;
          border-radius: 50%;
          vertical-align: middle;
        }
        span{
          margin-left: 10px;
          font-size: 20px;
        }
    }
  }
  .title{
    font-size: 18px;
    margin: 10px 0px;
    span{
      float: right;
      margin-right: 20px;
      color: #999;
      font-size: 16px;
    }
  }
  .content{
    .packUp{
      font-size: 16px;
      text-indent: 2em;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 3;
      overflow: hidden;
    }
    .expansion{
      font-size: 16px;
      text-indent: 1em;
    }
    span{
      float: right;
      font-size: 14px;
      color: #6854EC;
    }
    
  }

}
// 评论
.comment {
  h4 {
    padding: 10px;
  }
  ul {
    li {
      border-bottom: 1px solid #e3e4e4;
      overflow: hidden;
      padding: 10px;
      .com-Img {
        float: left;
        // width: 50px;
        // height: 50px;
        height: 100%;
        background: #f3f4f6;
        overflow: hidden;
        margin-right: 10px;
        img {
          display: block;
          width: 50px;
          height: 50px;
          border-radius: 50%;
          margin: 0 auto;
        }
      }
      .com-text {
        width: 548px;
        float: left;
        font-size: 16px;
        padding: 6px;
        p{
          margin: 0px;
          &.user {
            margin-bottom: 5px;
          }
          &.text {
            color: #666;
            font-size: 14px;
          }
        }
      }
    }
  }
}
// 视频
.videoBox {
  // width: 100%;
  background: #f3f4f6;
  position: relative;
  overflow: hidden;
  video {
    width: 100%;
    display: block;
  }
  .button {
    position: absolute;
    top: 0px;
    left: 10px;
    height: 40px;
    line-height: 40px;
    color: #fff;
    font-size: 18px;
  }
  .danmu {
    ul {
      li {
        position: absolute;
        top: 0px;
        left: 200%;
        color: #fff;
        animation:myfirst 10s;
      }
    }

    @keyframes myfirst {
      0% {
        left: 100%;
      }
      100% {
        left: -100%;
      }
    }
  }
  // span{
  //     position: absolute;
  //     top:0px;
  //     left:0px;
  //     right:0px;
  //     bottom:0px;
  //     margin:auto;
  //     width: 80px;
  //     height: 80px;
  //     text-align: center;
  //     line-height: 80px;
  //     color: #fff;
  //     font-size: 32px;
  //     background: rgba(0, 0, 0, .5);
  //     border-radius: 50%;
  // }
}
</style>
